package com.hntest.service.impl;

import com.hntest.dao.RechargeofflineDao;
import com.hntest.entity.Pager;
import com.hntest.entity.Rechargeoffline;
import com.hntest.service.RechargeofflineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service("rechargeofflineService")
public class RechargeofflineImpl implements RechargeofflineService {

    @Autowired
    private RechargeofflineDao rechargeofflineDao;

    @Override
    public int getCounts(Rechargeoffline rechargeoffline) {
        return rechargeofflineDao.getCounts(rechargeoffline);
    }

    @Override
    public List<Rechargeoffline> getListByPage(Pager pager, Rechargeoffline rechargeoffline) {
        Map<String,Object> map = new HashMap<String, Object>();
        map.put("rechargeoffline",rechargeoffline);
        map.put("pageStart",1);
        map.put("pageEnd",10000);
        int n = rechargeofflineDao.getListByPage(map).size();
        pager.setTotalCounts(n);
        map.put("pageStart",(pager.getCurrPage()-1)*pager.getPageSize()+1);
        map.put("pageEnd",pager.getCurrPage()*pager.getPageSize());
        List<Rechargeoffline> list= rechargeofflineDao.getListByPage(map);
        return list;
}

    @Override
    public int recharge(Rechargeoffline rechargeoffline) {
        System.out.println("正在充值");
        return rechargeofflineDao.recharge(rechargeoffline);
    }

    @Override
    public int pass(Rechargeoffline rechargeoffline) {
        System.out.println("审核通过中");
        return rechargeofflineDao.pass(rechargeoffline);
    }

    @Override
    public int refuse(Rechargeoffline rechargeoffline) {
        System.out.println("审核拒绝中");
        return rechargeofflineDao.refuse(rechargeoffline);
    }
}
